//
// Created by fh on 2021/6/30.
//

#ifndef CDEMO_GRAPH_H
#define CDEMO_GRAPH_H

#include <stdio.h>
#include <stdlib.h>
#include "CustomDefine.h"
#include "LinkQueue.h"
#include "LinkStack.h"
#include "LinkList.h"

/* 邻接矩阵图 */
#define N 8
typedef struct {
//    int v_count; /* 顶点个数 */
//    int (*v)[N]; /*  第一种表示方式：二维数组指针:指向int数组的指针 */
    int a[N][N]; /* 第二种表示方式：顶点 */
} AdjacencyMatrixGraph;

/* 邻接矩阵图创建初始化 */
AdjacencyMatrixGraph *AdjacencyMatrixGraphCreatAndInit(int count);
/* 邻接矩阵图广度优先遍历 */
void AdjacencyMatrixGraphBFSDisplay(AdjacencyMatrixGraph *graph,int s);
/* 邻接矩阵图广度优先搜索路径 */
void AdjacencyMatrixGraphBFSSearch(AdjacencyMatrixGraph *graph,int s,int t);
/* 邻接矩阵图深度优先遍历 */
void AdjacencyMatrixGraphDFSDisplay(AdjacencyMatrixGraph *graph,int s,int visited[N]);
/* 邻接矩阵图深度优先搜索 */
void AdjacencyMatrixGraphDFSSearch(AdjacencyMatrixGraph *graph,int s,int t,int visited[N],int pre[N]);
/* 打印邻接矩阵:数组 */
void AdjacencyMatrixGraphDisplay(AdjacencyMatrixGraph *graph);
/* 邻接矩阵图demo */
void AdjacencyMatrixGraphDemo();



#define M 30
/* 邻接表的链表 */
typedef struct {
    Node *head;
} AdjacencyList;

/* 邻接表图 */
typedef struct {
    AdjacencyList *array[M]; /* array是指向 AdjacencyList* 的数组 */
    int count; /* 顶点个数 */
    int directional; /* 是否是有向图:1有向、0无向 */
} AdjacencyListGraph;

/* 创建邻接表并初始化 */
AdjacencyListGraph *AdjacencyListGraphCreatAndInit(int count,int directional);
/* 在顶点insertIndex插入值insertValue */
Status AdjacencyListGraphInsert(AdjacencyListGraph *graph,int insertIndex,int insertValue);
/* 清空顶点关系/图 */
Status AdjacencyListGraphClear(AdjacencyListGraph *graph);
/* 释放内存 */
Status AdjacencyListGraphDealloc(AdjacencyListGraph **graph);

/* 打印邻接表 */
void AdjacencyListGraphDisplay(AdjacencyListGraph *graph);
/* 邻接表图demo */
void AdjacencyListGraphDemo();

#endif //CDEMO_GRAPH_H
